package main

import (
	"fmt"
	"net/http"
	"strings"
//	"io"
	"log"
)

func sayHelloName(w http.ResponseWriter,r *http.Request){
	r.ParseForm()//parse parameters
	fmt.Println("--------------------------------------------")
	fmt.Println(r.Form)
	fmt.Println("path", r.URL.Path)
    fmt.Println("scheme", r.URL.Scheme)
    fmt.Println(r.Form["url_long"])
	for k,v:=range r.Form {
		fmt.Println("key: ",k)
		fmt.Println("val: ",strings.Join(v," "))
	}
	fmt.Fprintf(w, "Hello astaxie!")
}

func main(){
	http.HandleFunc("/",sayHelloName)
//	http.HandleFunc("/",sayHelloName)
	er:=http.ListenAndServe(":9090",nil)
	if er!=nil{
		log.Fatal("ListenAndServe",er)
	}
}